home *** CD-ROM | disk | FTP | other *** search
- Path: arc-tac2-slip10.nsi.nasa.gov!rjtanner
- From: rjtanner@netcom.com (Rob Tanner)
- Newsgroups: comp.lang.c
- Subject: Q: How can I figure out the full path to myself! (UNIX)
- Followup-To: comp.lang.c
- Date: Mon, 19 Feb 96 00:53:48 GMT
- Organization: NAS/NASA Ames Research Center
- Message-ID: <rjtanner.1175078868A@cnn.nas.nasa.gov>
- NNTP-Posting-Host: arc-tac2-slip10.nsi.nasa.gov
- X-Newsreader: VersaTerm Link v1.1.5
-
-
- I am writing a "C" wrapper that will be used to accumulate statistics on
- the 100's of MB of public domain code my group maintains for the Center.
- Basically, when someone wants to execute one of the wrapped programs, what
- they really get is the wrapper which does some accounting kind of things
- (most people execute the programs were measuring from an NFS mounted
- filesystem) and then exec's the real executable which is stored one directory
- level beneath the wrapper.
-
- In order to be able to find the real executable, I always need to know the
- real absolute path to the wrapper, and since I have no control over all those
- other machines, that path can vary from machine to machine. In most cases
- that's not a problem since I can chase down the path from the information
- contained in argv[0].
-
- However, there are some exceptions. Login, for example, gets the path from
- login entry in /etc/passwd, but invokes the shell with only the name of the
- shell in argv[0], thus all the info I might get would be "tcsh" (or "-tcsh).
- Normally, I could chase down a user's path and find the execution instance,
- but during a login process there isn't sufficient path information in the
- environment to locate where I am executing from. Moreover, any process can
- exec another without providing sufficient path info in argv[0].
-
- Are there any tricks reading system/proc tables that someone could suggest?
- I'll need to port the wrappers to SunOS4, SunOS5, IRIX4, IRIX5, and IRIX6,
- so I hope there's a trick or tricks I can use for each of the platforms.
-
- Thanks,
- Rob Tanner
- _ _ _ _ _ _ _ _ _ _
- /\_\_\_\_\ /\_\ /\_\_\_\_\_\
- /\/_/_/_/_/ /\/_/ \/_/_/_/_/_/ QUIDQUID LATINE DICTUM SIT,
- /\/_/__\/_/ __ /\/_/ /\/_/ PROFUNDUM VIDITUR
- /\/_/_/_/_/ /\_\ /\/_/ /\/_/
- /\/_/ \/_/ /\/_/_/\/_/ /\/_/ (Whatever is said in Latin
- \/_/ \/_/ \/_/_/_/_/ \/_/ sounds profound)
-
- Rob Tanner
- rjtanner@netcom.com
- _____________________________________________________________________
-